package com.creative.accountsdk.net.account;

import com.creative.accountsdk.UserData;
import com.creative.accountsdk.net.Protocol;
import com.creative.accountsdk.net.XParams;
import com.loopj.android.http.RequestParams;

import org.json.JSONObject;

/**
 * Created by wang_qian on 2015/11/30.
 */
public class CheckClassInviteCodeProtocol extends Protocol {

    private UserData userData;
    private String  classInviteCode;
    public  String  className;
    private  JSONObject  jsonClass;


    public CheckClassInviteCodeProtocol(String  classinvitecode) {
        classInviteCode = classinvitecode;
        userData = UserData.getInstance();
    }

    @Override
    public RequestParams getParams() {
        long  uid = userData.getUid();

        return new XParams().put("uid", uid).put("cicode", classInviteCode).getParams();


    }

    @Override
    public String getUrl() {
        return getUrlPrefix()+"claz/info";
    }

    @Override
    protected void parseReturnMap(JSONObject returnMap) {
        jsonClass = returnMap.optJSONObject("class");
        if (jsonClass != null && jsonClass.has("name")) {
            className = jsonClass.optString("name");
        }
    }
}
